<template>
  <div
    class="exhibits-content"
    :class="{ 'home-box-loop': route.meta.loopType ? true : false }"
    :style="{ width: props.info.width + 'rem', height: props.info.height + 'rem' }"
  >
    <div class="list">
      <div class="item-parent" v-for="(item, index) in props.info.showpieceList" :key="index">
        <div
          @contextmenu.stop="emit('onContextMenuChild', $event, index)"
          class="exhibits-item border-hover-style exhibits-item1"
          :class="{ 'exhibits-item-0': index === 0 }"
        >
          <div
            v-if="(index + 1) % 2 === 0"
            @click="viewImg(item.moduleId, item.id)"
            class="item-parent-content item-parent-content-2"
            :style="{
              'background-image': `url(${publicUrls + 'free/style8/displayBoardStyle5Bg2.webp'})`,
            }"
          >
            <div
              class="cover-parent"
              :style="{
                'background-image': `url(${publicUrls + 'free/style8/displayBoardStyle5BgCover.webp'})`,
              }"
            >
              <div class="cover-box">
                <img class="cover" v-lazy="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')" alt="" />
              </div>
            </div>
            <div
              class="items-title"
              :style="{
                'background-image': `url(${publicUrls + 'free/style8/displayBoardStyle5Bgtitle.webp'})`,
              }"
            >
              <p class="title">{{ item.name }}</p>
            </div>
          </div>
          <div
            v-else
            @click="viewImg(item.moduleId, item.id)"
            class="item-parent-content"
            :style="{
              'background-image': `url(${publicUrls + 'free/style8/displayBoardStyle5Bg1.webp'})`,
            }"
          >
            <div
              class="items-title"
              :style="{
                'background-image': `url(${publicUrls + 'free/style8/displayBoardStyle5Bgtitle.webp'})`,
              }"
            >
              <p class="title">{{ item.name }}</p>
            </div>
            <div
              class="cover-parent"
              :style="{
                'background-image': `url(${publicUrls + 'free/style8/displayBoardStyle5BgCover.webp'})`,
              }"
            >
              <div class="cover-box">
                <img class="cover" v-lazy="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')" alt="" />
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free8Style3',
});
</script>

<script setup lang="ts">
import { useRoute } from 'vue-router';
import { urls, getLinkUrl } from '@/utils/request/upload';
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { defineComponent } from 'vue';

const route = useRoute();
const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const ImgVisible = ref(false);
const ImgUrl = ref('');

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});
const emitChildItemDraggable = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggable', draggingInfo, childIndex); //分组传递当前展品图距离相对父元素的xy偏移量变化
};
const emitChildItemDraggableStyle = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggableStyle', draggingInfo, childIndex); //分组设置当前展品图距离相对父元素的宽高变化
};
const emitShowcaseDraggable = (draggingInfo: any) => {
  emit('emitShowcaseDraggable', draggingInfo); //传递当前展柜图距离相对父元素的xy偏移量变化
};
const emitShowcaseDraggableStyle = (draggingInfo: any) => {
  emit('emitShowcaseDraggableStyle', draggingInfo); //传递当前展柜距离相对父元素的宽高变化
};
const getTitle = (name: string) => {
  if (name?.length !== 0) {
    if (name?.length <= 9) {
      return name;
    } else if (name) {
      let str = name.slice(0, 8);
      return str + '···';
    }
  }
};
const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};

// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.info.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script>

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  flex-direction: column;
  display: flex;
  z-index: 999;
  padding: 0px !important;
}
.list {
  display: flex; 
  justify-content: center; 
  width: 100%;
  height: 100%;
  -webkit-box-reflect: below 80px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
}
.item-parent {
  display: flex;
}
  
.exhibits-item {
  display: flex;
  flex-direction: column;
  width: 230px;
  height: 376.37px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  margin-left: 70px;
 .items-title {
    margin-top: 20px;
  }
  .cover-parent {
    margin-top: 35.3px;
  }
}
.exhibits-item-0 {
  margin-left: 0;
   .items-title {
    margin-top: 95px;
  }
  .cover-parent {
    margin-top: 20px;
  }
  
}
.item-parent-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  width: 230px;
  height: 376.37px;
  //   box-shadow: 2px 0px 2px 0px rgba(0, 0, 0, 0.3);
  padding: 0px 23px 0px 16px;
}
.item-parent-content-2 {
}
.items-title {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 190px;
  height: 40px;
  padding: 6px 3px 6px 4px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  .title {
    width: 183px;
    height: 28px;
    font-family: SourceHanSerifCN-Bold;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    color: rgba(255, 255, 255, 1);
    line-height: 28px;
  }
}
.cover-parent {
  display: flex;
  width: 191px;
  height: 186px;
  box-shadow: 2px 0px 2px 0px rgba(0, 0, 0, 0.3);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 6px;
  padding-right: 11px;
}
.cover-box {
  position: relative;
  overflow: hidden;
  width: 174px;
  height: 174px;
}
.cover {
  width: 174px;
  height: 174px;
  object-fit: contain;
  transition: all 0.3s;
}
.cover-box:hover {
  .cover {
    transform: scale(1.2);
  }
}
.flower-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.3);
  border: 3px solid #ffffff;
  border-radius: 50%;
  div {
    width: 12.5px;
    height: 12.5px;
    background: #ffffff;
    border-radius: 50%;
  }
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  transform: translate(-50%, -50%);
  animation: flower 2s linear infinite;
  @keyframes flower {
    0% {
      opacity: 0;
    }
    40% {
      opacity: 100%;
    }
    80% {
      opacity: 100%;
    }
    100% {
      opacity: 0;
    }
  }
}
</style>
